<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/resources/common/commonTaglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 导入资源文件 -->
<%@include file="/resources/common/commonJs.jsp" %>
<%@include file="/resources/common/commonCss.jsp" %>
<title>校车时刻表</title>
<script type="text/javascript">
//校车预约
function busBespeak(scheduleId) {
	window.location.href = '${path}/busBespeak/toTeacherApplyPage?scheduleId='+scheduleId;
}
var compareDate = function(date) {
	var nowDate = new Date();
	//时分秒
	var hour = nowDate.getHours();
	var minute = nowDate.getMinutes();
	var seconds = nowDate.getSeconds();
	if (hour > date.getHours()) {
		return true;
	} else if (hour < date.getHours()) {
		return false;
	} else {
		if (minute > date.getMinutes()) {
			return true;
		} else if (minute < date.getMinutes()) {
			return false;
		} else {
			if (seconds >= date.getSeconds()) {
				return true;
			} else {
				return false;
			}
		}
	}
}

$(function() {
	$('.startTimeShow').each(function(index, element) {
		var startTime = $(element).html();
		var data = new Date('1970/1/1 '+startTime);
		if (compareDate(data)) {
			$(element).parent().find('td:last').html('不可预约');
		}
	});
	
})
</script>
</head>
<body>
<div style="width: 90%; margin-left: 5%; height: 38px; font-size: 24px; text-align: center; background-color: #DDF3F5">
	校车车次时刻表
</div>
<!-- 数据列表的显示start -->
<div class="listDataTableStyle">
	<table cellpadding="0" cellspacing="0" width="100%">
		<thead>
		<tr>
			<th>序号</th>
			<th>始发站</th>
			<th>终点站</th>
			<th>发车时间</th>
			<th>到达时间</th>
			<th>当前状态</th>
			<th>已预约人数</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<c:if test="${empty page.content }">
			<tr><td colspan="12">没有校车时刻信息</td></tr>
		</c:if>
		<c:if test="${!empty page.content }">
		<c:forEach items="${page.content }" var="data" varStatus="index">
		<tr>
			<td>${index.index + 1}</td>
			<td>${data.startStation == 1 ? '金花校区' : '临潼校区' }</td>
			<td>${data.endStation == 1 ? '金花校区' : '临潼校区' }</td>
			<td class="startTimeShow"><fmt:formatDate value="${data.startTime }" pattern="HH:mm:ss"/></td>
			<td><fmt:formatDate value="${data.endTime }" pattern="HH:mm:ss"/></td>
			<td>${data.currentStatus }</td>
			<td>${data.personNum }</td>
			<td>
				<a href="javascript:;" class="icon-minus-sign" onclick="busBespeak('${data.id}')">校车预约</a>
			</td>
		</tr>
		</c:forEach>
		</c:if>
		</tbody>
	</table>
</div>
<!-- 数据列表的显示end -->
<!-- 分页start -->	
<table width="100%">
	<tr>
		<td width="20%">
			<div class="pagin" style="margin-top: 0px !important;">
				<div style="font-size: 14px; font-family: Helvetica Neue,Helvetica,Arial,sans-serif">共<i style="color: blue;">${page.totalElements }</i>条记录，当前第&nbsp;<i style="color: blue;">${page.number+1 }&nbsp;</i>页</div>
			</div>
		</td>
		<td>	
			<div id="Pagination" class="pagination" style="float:right;margin-right:20px;">
			<script type="text/javascript">
					$(document).ready(function(){
						//获取起始页	 
					  	$("#Pagination").pagination('${page.totalElements}', {//总页数
						  num_edge_entries : 2,//分页页码段右的页码个数
						  num_display_entries : 5,//分页页码段右的页码个数
						  callback : pageselectCallback,//回调函数
						  current_page : ${page.number},//当前页
						  items_per_page :'${page.size}'//每页多少条
					  	});
					});
					
					//分页回调函数
					function pageselectCallback(start, jq){
						$('#pageNumber').val(start);
						search(false);
					}
					//查询方法
				    function search(resetPageNum){
				    	if(resetPageNum){
					        $('#pageNumber').val(0);//重置分页参数,由于分页时也调用此方法，所以增加判断
						}
				        $('#searchForm').submit();
				    }
				    //重置
				    function resetSform(){
						location.href = '#';
				    } 
				</script>
		    </div>
		</td> 
	</tr>
</table>
<!-- 分页end -->
</body>
</html>